package proxy.stat;

/**
 * 静态代理
 * 优点:
 * 1.使用简单方便,容易理解
 * 缺点:
 * 1.如果代理多个类,需要创建多个代理类
 * 2.如果原有类对象增减了方法,那么代理类也需要发生改变,如果有非常多该对象的代理类,那么工作量就非常大
 * Created By Lu Chuan On 2019/11/23
 */
public class ServiceProxy implements Service {
	private ServiceImpl service;
	
	public ServiceProxy(ServiceImpl service) {
		this.service = service;
	}
	
	@Override
	public void method() {
		doSomethingBefore();
		service.method();
		doSomethingAfter();
	}
	
	private void doSomethingBefore() {
		System.out.println("do something before");
	}
	
	private void doSomethingAfter() {
		System.out.println("do something after");
	}
}
